// pages/img/detail.js
let app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    zan:0,
    favor:0,
    share:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that = this;
    console.log(options);
    var id = options.id;
    this.setData({
        id:id
    })
    this.getDetail(id);
    this.setData({
      domain:app.globalData.domain,
      width:app.globalData.windowWidth,
      height:app.globalData.windowHeight,
      safeHeight:app.globalData.safeHeight,
      statusBarHeight:app.globalData.statusBarHeight,
      navHeight:app.globalData.navHeight,
      marginTop:app.globalData.navTitleTop
    });
  },
  goBack:function(){
    wx.navigateBack();
  },
  getDetail: function (id){
    wx.showLoading({							
      title: '加载中...',
    })
    var that = this;
    var page=this.data.page;
    wx.request({
      url: app.globalData.domain+'wechat/face/getImageDetail',
      data: {
          id:id,
         // page:page
    },
      success:function(res){
        wx.hideLoading();
        console.log(res);
        var img = res.data.img;
        that.setData({
            img:img,
          //swiperList: contentlist.swiperList
        })
        ////console.log(that.data.matchListData)
      },
      fail:function(){
      }
    })
  },
  setZan(){
    var that = this;
    var id=this.data.id;
    var zan=this.data.zan;
    wx.request({
      url: app.globalData.domain+'wechat/face/setImageZan',
      data: {
          id:id,
         zan:zan,
         // page:page
    },
      success:function(res){
        //wx.hideLoading();
        console.log(res);
        var data = res.data;
        that.setData({
            zanNum:data.zanNum,
            zan:data.zan

          //swiperList: contentlist.swiperList
        })
        ////console.log(that.data.matchListData)
      },
      fail:function(){
      }
    })
  },
  setFavor(){
    var that = this;
    var id=this.data.id;
    var favor=this.data.favor;
    wx.request({
      url: app.globalData.domain+'wechat/face/setImageFavor',
      data: {
          id:id,
         favor:favor,
         // page:page
    },
      success:function(res){
        //wx.hideLoading();
        console.log(res);
        var data = res.data;
        that.setData({
            //zanNum:data.zanNum,
            favor:data.favor

          //swiperList: contentlist.swiperList
        })
        ////console.log(that.data.matchListData)
      },
      fail:function(){
      }
    }) 
},
setShare(){
    this.setData({
        share:1
    })  
},
hiddenShare(){
    this.setData({
        share:0
    })  
},
    setDown(){
        var id = this.data.id;
        wx.navigateTo({
            url: 'down?id='+id,
          }) 
    },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})